//
//  Extension+Array.swift
//  TCMHealth
//
//  Created by 韩颖 on 2023/7/2.
//

import Foundation
extension Array {
    
    /// 数组内中文按拼音字母排序
    ///
    /// - Parameter ascending: 是否升序（默认升序）
    func sortedByPinyin(ascending: Bool = true) -> Array<String> {
        if self is Array<String> {
            return (self as! Array<String>).sorted { (value1, value2) -> Bool in
//                let pinyin1 = value1.transformToPinyin()
//                let pinyin2 = value2.transformToPinyin()
                return value1.compare(value2) == (ascending ? .orderedAscending : .orderedDescending)
            }
        }
        return []
    }
    
  
}
